Open Database

  • open pgAdmin4


  • Login the database by password
  • Click all of the databases


Open SQL editor

  • Click the database (CIQ_Target)
  • Open the editor


CSV

  • Copy the SQL code down below
COPY
(select ELD.datavalue as Country, 
DTC.orgDebtType,
RD.ratingTypeCode,
RD.currentRatingSymbol as Current_Rating,
RD.ratingDate as Rating_Date,
RD.creditwatch as SP_Potential_Direction,
RD.creditwatchDate as SP_Potential_Direction_Date,
RD.outlook as SP_Potential_Direction_long_term,
RD.outlookDate as SP_Potential_Direction_long_term_Date

from spRatingData as RD
join spEntityLevelData as ELD on RD.entitySymbolvalue = ELD.entitySymbolvalue and ratingDataItemId = 21 --指定篩選項目為國家
join spRatigOrgDebtType as DTC on RD.orgDebtTypeCode = DTC.orgDebtTypeCode
where datavalue = 'USA') --指定篩出USA

to 'D:\ratingData.csv' delimiter ',' csv HEADER ENCODING 'UTF8'
  • Paste and run (press the play botton)

  • It will return the “Query returned successfully in few msec.” in Messages if the code works.